package com.ymatou.startApp;

import java.io.IOException;

import android.os.RemoteException;

import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.ymatou.util.Logger;

@SuppressWarnings("deprecation")
public class CheckGuideTest extends UiAutomatorTestCase {
	
	private static final String TAG = CheckGuideTest.class.getSimpleName();

	public static void checkGuide() throws IOException, UiObjectNotFoundException, RemoteException {
        
        //检查开机引导页
        UiSelector vpGuides_s = new UiSelector().resourceId("com.ymatou.shop:id/vpGuides");
		UiSelector guide_start_s = new UiSelector().resourceId("com.ymatou.shop:id/iv_guide_start_now");
        
		UiObject guide_start_o = new UiObject(guide_start_s);
		UiObject vpGuides_o = new UiObject(vpGuides_s);

		vpGuides_o.waitForExists(5000);
		while (vpGuides_o.exists()) {
			Logger.log(TAG, "存在开机引导页");
			
			if (guide_start_o.exists()) {
				guide_start_o.click();
				Logger.log(TAG, "点击进入首页");
				return;
			}
			vpGuides_o.swipeLeft(10);
		}
    }
}
